<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    template="base.xhtml">
    
    <ui:define name="metadata">
		<f:event listener="#{clubBean.init}" type="preRenderView" />
    </ui:define>
    
    <ui:param name="bean" value="#{clubBean}"/>
    
    <ui:define name="content">
        <h2>Clubs</h2>
        <h:form id="form">
        	<h3>Add club</h3>
        	<p:panelGrid>
        		<p:row>
        			<p:column>
        				<p:outputLabel for="code" value="Code * : "/>
        			</p:column>
   			  		<p:column>
   			  			<p:inputText id="code" value="#{bean.newClub.code}" />
        			</p:column>
        		</p:row>
        		<p:row>
        			<p:column>
        				<p:outputLabel for="name" value="Name * : "/>
        			</p:column>
   			  		<p:column>
   			  			<p:inputText id="name" value="#{bean.newClub.name}"/>
        			</p:column>
        		</p:row>
        	</p:panelGrid>
        	
        	<p:commandButton value="Create" actionListener="#{clubBean.add}" update="form" styleClass="submit"/>
        	
        	<h3>All clubs</h3>
        	<p:dataTable id="table" var="club" value="#{bean.model}">
        		<p:column style="width:4%">  
                	<p:commandButton id="selectButton" action="#{clubBean.remove}" icon="ui-icon-trash" title="Delete">  
                		<f:setPropertyActionListener value="#{club}" target="#{clubBean.clubToDelete}" />  
        	    	</p:commandButton>  
		        </p:column>  
        		<p:column headerText="Code">
        			#{club.code}
        		</p:column>
        		<p:column headerText="Name">
        			#{club.name}
        		</p:column>
        	</p:dataTable>
        </h:form>
    </ui:define>
</ui:composition>